package com.caocaog.market.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.system.base.entity.AllEntity;

import java.io.Serializable;

/**
 * 商品基础信息
 *
 * @author chechen
 * @date 2022-04-18
 */
@Data
@Accessors(chain = true)
@TableName("mk_goods_basic")
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "mk_goods_basic对象", description = "商品基础信息")
public class GoodsBase extends AllEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "ID")
    private String id;

    @ApiModelProperty(value = "商品全称")
    private String name;

    @ApiModelProperty(value = "商品简称")
    private String shortName;

    @Dict(dictTable = "mk_goods_sort", dicText = "name", dicCode = "id")
    @ApiModelProperty(value = "商品分类")
    private String sorts;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "商品原价")
    private String originalPrice;

    @ApiModelProperty(value = "商品现价")
    private String presentPrice;

    @ApiModelProperty(value = "商品代码")
    private String code;

    @ApiModelProperty(value = "商品图片")
    private String picture;

    @ApiModelProperty(value = "商品描述")
    private String description;

    @Deprecated
    @ApiModelProperty(value = "商品描述")
    private String shortDescription;

    @ApiModelProperty(value = "商品描述")
    private String goodDetail;

    @ApiModelProperty(value = "商品供应商")
    private String goodBrand;

    @Dict(dicCode = "mk_goods_status")
    @ApiModelProperty(value = "商品上下架状态 1上架0下架")
    private String status;

    @ApiModelProperty("商品销量")
    private Integer textMonthly;

    public GoodsBase reverseStatus() {
        this.status = this.status.equals("1") ? "0" : "1";
        return this;
    }

    /**
     * 销量自增
     * @return 销量自增方法
     */
    public GoodsBase increaseTextMonthly() {
        this.textMonthly = this.textMonthly == null ? 1 : ++this.textMonthly;
        return this;
    }

    @Dict(dicCode = "mk_whether")
    @ApiModelProperty(value = "是否首页展示")
    private String isIndex;

    public GoodsBase reverseIndex() {
        this.isIndex = this.isIndex.equals("1") ? "0" : "1";
        return this;
    }

    @Dict(dicCode = "mk_whether")
    @ApiModelProperty(value = "是否热门商品")
    private String isHot;

    public GoodsBase reverseHot() {
        this.isHot = this.isHot.equals("1") ? "0" : "1";
        return this;
    }

    @Dict(dicCode = "mk_whether")
    @ApiModelProperty(value = "是否单点不送")
    private String oneNoDelivery;

    public GoodsBase reverseOneNoDelivery() {
        this.oneNoDelivery = this.oneNoDelivery.equals("1") ? "0" : "1";
        return this;
    }

    @ApiModelProperty(value = "浏览次数")
    private Integer visitNum;

    @ApiModelProperty(value = "销售数量")
    private Integer saleNum;

    @ApiModelProperty(value = "关联店铺表（mk_shop_basic表中的id字段）；店铺id")
    @Dict(dictTable = "mk_shop_basic", dicCode = "id", dicText = "name")
    private String shopId;

    @ApiModelProperty(value = "起售数量")
    private Integer salesQuantity;

    @ApiModelProperty(value = "是否是单个规格")
    private Boolean singleSpec;

}
